<?php

namespace App\Pool;


use Swoole\Coroutine;
use Swoole\Coroutine\Channel;
use Swoole\Runtime;

class Redis
{
    public static function getDriver()
    {
        return app('redis_pool');
    }

    public static function __callStatic($name, $arguments)
    {
        Runtime::enableCoroutine();
        $channel = new Channel(1);
        Coroutine::create(function () use ($channel, $name, $arguments) {
            $redis  = self::getDriver();
            $return = $redis->$name(...$arguments);
            $channel->push($return);
        });

        return $channel->pop();
    }
}